package main

import (
	"github.com/bitly/go-simplejson"
	"regexp"
	"sync"
)

type Exporter interface {
	export()
	loadMetric([]string)
}

type Timer interface {
	refresh(int64)
}

type Metric interface {
	getMetric(string) []string
}

type Host struct {
	stopping chan interface{}
	stopped  chan interface{}
	mu       sync.RWMutex
	tags     map[string]string
	metrics  []Metric
	mdata    []string
}

type Proc struct {
	stopping chan interface{}
	stopped  chan interface{}
	mu       sync.RWMutex
	tags     map[string]string
	metrics  []Metric
	mdata    []string
}

type ProcessItem struct {
	MatchMulti     bool              `json:"match_multi"`
	ProcessPattern string            `json:"pattern"`
	Tags           map[string]string `json:"tags"` //with tags params
	process        Process
	reg            *regexp.Regexp
}

type pwMetric struct {
	stat     *Status
	duration int64
}

type Process interface {
	Status(string) (*Status, error)
	Add(int64, int) error
	Uptime() int64
}

type SingleProcess struct {
	pid       int
	ctime     int64
	checkTime int64
}

type MultiProcess struct {
	processes []*SingleProcess
}

type Status struct {
	ProcType    string
	ProcCount   int32
	CuTime      int64
	CsTime      int64
	STime       int64
	UTime       int64
	MemSize     int64
	ThreadCount int32
	ReadCount   uint64
	WriteCount  uint64
	ReadBytes   uint64
	WriteBytes  uint64
	BytesSent   uint64
	BytesRecv   uint64
	PacketsSent uint64
	PacketsRecv uint64
	CpuUsage    float64
	CheckTime   int64
}

type NetCheck struct {
	cks          *simplejson.Json
	wgp          sync.WaitGroup
	lastScanTime int64
	metricStr    []string
}

type Ping struct {
	ips          string
	wg           sync.WaitGroup
	lastScanTime int64
	metricStr    []string
}

type HostBase struct {
	interval     int64
	lastScanTime int64
	metricStr    []string
	netInfo      map[string]float64
}

type ProcBase struct {
	interval     int64
	lastScanTime int64
	metricStr    []string
	confdir      string
}
